package io.renren.modules.eas.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;
import io.renren.modules.eas.entity.EasBasicSchoolEntity;
import io.renren.modules.eas.service.EasBasicSchoolService;



/**
 * 学校表
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2023-09-26 23:32:06
 */
@RestController
@RequestMapping("eas/easbasicschool")
public class EasBasicSchoolController {
    @Autowired
    private EasBasicSchoolService easBasicSchoolService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("eas:easbasicschool:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = easBasicSchoolService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("eas:easbasicschool:info")
    public R info(@PathVariable("id") Long id){
		EasBasicSchoolEntity easBasicSchool = easBasicSchoolService.getById(id);

        return R.ok().put("easBasicSchool", easBasicSchool);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("eas:easbasicschool:save")
    public R save(@RequestBody EasBasicSchoolEntity easBasicSchool){
		easBasicSchoolService.save(easBasicSchool);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("eas:easbasicschool:update")
    public R update(@RequestBody EasBasicSchoolEntity easBasicSchool){
		easBasicSchoolService.updateById(easBasicSchool);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("eas:easbasicschool:delete")
    public R delete(@RequestBody Long[] ids){
		easBasicSchoolService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

    /**
     * 搜索
     */
    @RequestMapping("/search")
    public R search(@RequestParam Map<String, Object> params, @RequestParam String search){
        PageUtils page = easBasicSchoolService.searchPage(params, search);

        return R.ok().put("page", page);
    }
}
